package cn.edu.scnu.show_and_find_movies.service;

import cn.edu.scnu.show_and_find_movies.mapper.ShowMapper;
import cn.edu.scnu.show_and_find_movies.model.Movie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShowServiceImpl implements ShowService {
    @Autowired
    ShowMapper showMapper;

    @Override
    public List<Movie> getHotMovies() {
        List<Movie> movies = showMapper.getHotMovies();
        int i=1;
        for(Movie movie:movies){
            movie.setHotRank(i++);
        }
        return movies;
    }

    @Override
    public List<Movie> getMoviesByType(String type) {
        return showMapper.getMoviesByType(type);
    }
    @Override
    public List<Movie> getMoviesByRegion(String region) {
        return showMapper.getMoviesByRegion(region);
    }

    @Override
    public Movie getMovieById(Integer movieId) {
        return showMapper.getMovieById(movieId);
    }
}
